﻿using System.Collections.Generic;
using CivilRegistry.ControlledModel.Repository;

namespace CivilRegistry.ControlledModel
{
    /// <summary>
    /// The <see cref="RationCard"/> alter request type.
    /// </summary>
    public partial class RationCardAlterRequestType
    {
        #region Local Fields

        /// <summary>
        /// Holds the <see cref="RationCardAlterRequestTypeRepository"/> instance.
        /// </summary>
        static RationCardAlterRequestTypeRepository repository = new RationCardAlterRequestTypeRepository();

        #endregion

        #region Methods

        #region Finder Methods

        /// <summary>
        /// Finds the <see cref="RationCardAlterRequestType"/> by Id.
        /// </summary>
        /// <param name="id">The id of the <see cref="RationCardAlterRequestType"/>.</param>
        /// <returns>Found <see cref="RationCardAlterRequestType"/> object, null if not found.</returns>
        public static RationCardAlterRequestType FindById(int id)
        {
            return repository.FindBy(rationCardAlterRequestType => rationCardAlterRequestType.RationCardAlterRequestTypeId == id);
        }

        /// <summary>
        /// Finds the <see cref="RationCardAlterRequestType"/> by name.
        /// </summary>
        /// <param name="name">The <see cref="RationCardAlterRequestType"/> name.</param>
        /// <returns>Found <see cref="RationCardAlterRequestType"/> object, null if not found.</returns>
        public static RationCardAlterRequestType FindByName(string name)
        {
            return repository.FindBy(rationCardAlterRequestType => rationCardAlterRequestType.RationCardAlterRequestTypeName == name);
        }

        /// <summary>
        /// Finds all <see cref="RationCardAlterRequestType"/>s.
        /// </summary>
        /// <returns>Found <see cref="RationCardAlterRequestType"/> objects, empty if none are found.</returns>
        public static List<RationCardAlterRequestType> FindAll()
        {
            List<RationCardAlterRequestType> rationCardAlterRequestTypeList = new List<RationCardAlterRequestType>();
            repository.FindAll().ForEach(rationCardAlterRequestType => rationCardAlterRequestTypeList.Add(rationCardAlterRequestType));
            return rationCardAlterRequestTypeList;
        }

        #endregion

        #endregion
    }
}
